package solution;

/**
 * Created by wangxingsheng on 2019/8/9.
 * 给定一个字符串，请你找出其中不含有重复字符的 最长子串 的长度。
 */
public class LengthOfLongestSubstring {
    private int count = 0;

    public int lengthOfLongestSubstring(String s) {
        System.out.println(s);
        int count2 = 0;
        for (int i = 0; i < s.length(); i++) {
            int index = s.indexOf(s.charAt(i));
            if (index != i) {
                if (i >= count) {
                    count = i;
                    return lengthOfLongestSubstring(s.substring(index + 1));
                }
            } else {
                count2++;
            }
        }
        if (count2 > count) {
            count = count2;
        }
        return count;
    }

    public static void main(String[] args) {
        //todo 未解决
        String test = "fbojelwjgercer";
        LengthOfLongestSubstring substring = new LengthOfLongestSubstring();
        System.out.println(substring.lengthOfLongestSubstring(test));
    }
}
